$(function() {
	$("#header").load('header.html', function() {
		loadHeader(1)
	});
	$("#footer").load('footer.html', function(data, status, xhr) {});
	$("#tab").load('tab.html', function(data, status, xhr) {});
	//获取url中的参数
	function getUrlParam(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
		var r = window.location.search.substr(1).match(reg); //匹配目标参数
		if(r != null) return unescape(r[2]);
		return null; //返回参数值
	}
	//接收URL中的参数booksId
	var id = getUrlParam('mid');
	$('.doc-pro-r').show()
	$('.case-center-r').hide()
	$('.doc-pro-l').on('click', '.doc-pro-item-1', function() {
		$('.doc-pro-r').show()
		$('.case-center-r').hide()
		$('.doc-pro-l li:eq(0)').addClass('active').siblings('.active').removeClass('active')
	})
	$('.doc-pro-l').on('click', '.doc-pro-item-2', function() {
		$('.doc-pro-r').hide()
		$('.case-center-r').show()
		$('.doc-pro-l li:eq(1)').addClass('active').siblings('.active').removeClass('active')
	})
	$.ajax({
		url: host + '/MtmlAPI/DoctorDetails',
		type: 'POST',
		dataType: 'JSON',
		data: {
			cid: cid,
			mid: id
		},

		success: function(res) {
			var obj = res.data
			var tag = obj.Tags.replace(/\|/g, "、").slice(0, -1)
//			console.log(tag)
			if(res.state) {
				$('.doc-pro-r').append(
					`
				<div class="doc-pro-r-top">
					<div class='doc-pro-r-img' style='background-image: url(${obj.HeadImage});'></div>
					<div class="doc-pro-r-r">
						<div class="doc-pro-name">${obj.RealName}</div>
						<div class="doc-pro-ho">所属医院: ${obj.HospitalName}</div>
						<ul class="doc-pro-job">
							<li>
								<i class="iconfont icon-wujiaoxing"></i>
								<span>${obj.Position}</span>
							</li>
							
						</ul>
						<div class="doc-pro-bueno">擅长项目: ${tag}</div>
					</div>
				</div>
				<div class="doc-pro-txt">${obj.Introduce}</div>
				
				`
				);
				//				<ul class="doc-pro-imglist">
				//					<li><img src="../img/doctor/名医在线-医生介绍_07.png" /></li>
				//					<li><img src="../img/doctor/名医在线-医生介绍_07.png" /></li>
				//					<li><img src="../img/doctor/名医在线-医生介绍_07.png" /></li>
				//				</ul>
			} else {

			}
		},
		error: function() {}
	});
	$.ajax({

		url: host + '/MtmlAPI/SucessCaseList',
		type: 'post',
		dataType: 'JSON',
		data: {
			types: 2,
			cid: cid,
			mid: id,
			index: 1,
			size: 100
		},

		success: function(res) {
			var obj = res.data
			if(res.state) {
				for(var i = 0; i < obj.list.length; i++) {
					var pro = obj.list[i].Operation.split(",");
					$('.case-list').append(
						`
               		<li onclick="location.href='case-detail.html?{obj[i].mid}'" style='width:476px;'>
					<div class="case-item-img">
						<div class="case-item-img-l">
							<img src="${obj.list[i].skulist[0].img}" height='198' width='188'/>
							<div>BEFORE</div>
						</div>
						<div class="case-item-img-l case-item-img-r">
							<div>AFTER</div>
							<img src="${obj.list[i].skulist[1].img}" height='198' width='188'/>

						</div>
					</div>
					<ul class="case-item-txt">
						<li>
							<div class="case-per">
								<div>姓名： ${obj.list[i].PatientName}</div>
								<div>医生: ${obj.list[i].DocName}</div>
							</div>
						</li>
						<li> 治疗前: <br /> ${obj.list[i].skulist[0].Describe}
						</li>
						<li>治疗后: <br />${obj.list[i].skulist[1].Describe}
						</li>
						<li>
							<ul class="case-project">
							</ul>
						</li>
					</ul>
				</li>

				`
					);
//					var tab = obj[i].Operation.split(",");
//
//					for(var b = 0; b < tab.length - 1; b++) {
//						$('.case-project').append(`<li><span>·</span><span>${tab[b]}</span></li>`)
//					};

				}
			} else {

			}
		},
		error: function() {}
	});
});